{# Stalker Pyramid a Web Base Production Asset Management System
 Copyright (C) 2009-2014 Erkan Ozgur Yilmaz

 This file is part of Stalker Pyramid.

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation;
 version 2.1 of the License.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#}
{% extends "base.jinja2" %}

{# SIDEBAR #}
{% block sidebar %}

    {% include 'sidebar.jinja2' %}

{% endblock sidebar %}

{# BREADCRUMBS #}
{% block breadcrumbs %}

    {% set page_title='Departments' %}
    {% include 'breadcrumb/breadcrumbs.jinja2' %}

{% endblock breadcrumbs %}


{# PAGE-CONTENT #}
{% block page_content %}
    {% set page_title='Departments' %}
    {% include 'page_header.jinja2' %}


    {% set add_button_address='/departments/create/dialog?came_from='+ request.current_route_path() %}
    {% set address=request.route_path('get_entity_departments', id=entity.id) %}
    {% set list_item_type='Department' %}
    {% include 'components/data_table.jinja2' %}

{% endblock page_content %}

{# EXTRA-SCRIPTS #}
{% block extrascripts %}

    {% raw %}
    <script id="tmpl_itemThead" type="text/x-dot-template">

    <tr>
        <th>Thumbnail</th>
        <th>Department</th>
        <th>Lead</th>
        <th>Users</th>
        <th>Created By</th>
        <th></th>
    </tr>
    </script>
    {% endraw %}

    {% raw %}
    <script id="tmpl_itemRow" type="text/x-dot-template">
        <tr>
            <td><img style='width:auto; height: 50px;'
                     class="img-thumbnail"
                     src="{{=it.thumbnail_full_path }}">
            </td>
            <td><a href='/departments/{{=it.id }}/view'>{{=it.name}}</a>
            </td>
            <td><a href='/users/{{=it.lead_id}}/view'>{{=it.lead_name}}</a>
            </td>
            <td>{{=it.users_count}}</td>
            <td><a href='/users/{{=it.created_by_id}}/view'>{{=it.created_by_name}}</a>
            </td>

            <td>
                 {{ if (it.update_department_action) { }}
                <a  class="blue"

                    href="{{=it.update_department_action}}">
                    <i class="icon-edit bigger-130"></i>
                </a>{{ } }}

                {{ if (it.delete_department_action) { }}
                <a  class="red"
                    data-target="#dialog_template"
                    data-toggle="modal"
                    data-keyboard=false
                    href="{{=it.delete_department_action}}?came_from={{=it.came_from }}">
                    <i class="icon-trash bigger-130"></i>
                </a>{{ } }}
            </td>

        </tr>
    </script>
    {% endraw %}

    <script>

        var tableParameters = {}
        var sortingParameters = [[0, 'asc'], [1, 'desc']]
        var tableDataAddress = '{{ request.route_path('get_entity_departments', id=entity.id) }}'

     console.log('tableDataAddress' + tableDataAddress)

    </script>

{% endblock extrascripts %}
